package com.lh.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lh.project.model.entity.Bill;
import com.lh.project.model.entity.Food;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @Entity com.lh.project.model.entity.Bill
*/
public interface BillMapper extends BaseMapper<Bill> {



    @Select("select * from bill where user_id=${userId} and expired_time > now()")
    @Results({
            @Result(column = "bill_id" ,property = "billId"),
            @Result(column = "bill_number",property = "billNumber"),
            @Result(column = "bill_order_id",property = "billOrderId"),
            @Result(column = "bill_value",property = "billValue"),
            @Result(column = "expired_time",property = "expiredTime"),
            @Result(column = "status",property = "status"),
            @Result(column = "food_id",property = "food",javaType = Food.class,
                one = @One(select = "com.lh.project.mapper.FoodMapper.selectById")
            ),
            @Result(column = "create_time",property = "createTime"),
            @Result(column = "is_delete",property = "isDelete")
    })
    List<Bill> getBillByUserId(Long userId);
}
